package cn.zf233.xcloud.service.impl;

import cn.zf233.xcloud.config.common.ElasticSearchConfig;
import cn.zf233.xcloud.config.common.RabbitMQConfig;
import cn.zf233.xcloud.entity.File;
import cn.zf233.xcloud.entity.User;
import cn.zf233.xcloud.mapper.FileMapper;
import cn.zf233.xcloud.service.SearchService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zf233 on 2021/6/4
 * 简陋的搜索服务
 */
@Service
@ConditionalOnMissingBean({ElasticSearchConfig.class, RabbitMQConfig.class})
public class SearchSimpleServiceImpl implements SearchService {

    @Resource
    private FileMapper fileMapper;

    @Override
    public void buildIndex() {

    }

    @Override
    public void clearIndex() {

    }

    @Override
    public List<File> search(User user, String keyword) {
        return fileMapper.selectFilesByUserIDAndMatchCode(user.getId(), keyword);
    }

    @Override
    public List<File> search(CriteriaQuery query) {
        return null;
    }

    @Override
    public List<File> classify(User user, Integer classify) {
        return fileMapper.selectFilesByUserIDAndClassify(user.getId(), classify);
    }

    @Override
    public List<File> recycle(User user) {
        return fileMapper.selectFilesByUserIDAndDeleteFlag(user.getId());
    }

    @Override
    public void insertBatch(List<File> fileList) {

    }

    @Override
    public void deleteBatch(List<File> fileList) {

    }

    @Override
    public void insertOrUpdateOne(File file) {

    }

    @Override
    public void deleteOne(File file) {

    }
}
